<?php
session_start();
$cdnjsUrl='http://tu-10030004.file.myqcloud.com/zhun';
$url='.';
$urlHook=array('p1','info','z','print','home');
if(isset($_GET['c'])){
    $c=$_GET['c'];
    if (in_array($c, $urlHook)){
        include($c.'.php');
    }
    exit;
}

if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) { //in weixin
    if (!isset($_SESSION['openid'])){
        header("Content-Type:text/html;charset=UTF-8");
        include_once './c/config.php';
        $redirect_uri = urlencode('http://mei94.com/zhun/b.php');
        $api_userinfo_base='https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$appId.'&redirect_uri='.$redirect_uri.'&response_type=code&scope=snsapi_base#wechat_redirect';
        header('Location: '.$api_userinfo_base);
        exit;
    }
    if (isset($_SESSION['openid'])) {
    	include_once './c/config.php';
    	$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
        if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}
    	$queryJ=$mysqli->query("SELECT id from `app_student` where openid='".$_SESSION['openid']."' limit 0,1 ");
	    if($queryJ->num_rows>0){
            $getUid=$queryJ->fetch_array();
            $_SESSION['uid']=$getUid['id'];
            header('Location: ?c=z');
            exit;
	    }
    }
    
    

}

include 'home.php';
